package com.iknow.data;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import com.iknow.IKnow;
import com.iknow.db.IKnowDataBase;
import com.iknow.util.StringUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Word
  implements Parcelable
{
  public static final Parcelable.Creator<Word> CREATOR = new Parcelable.Creator()
  {
    public Word createFromParcel()
    {
      return new Word(paramParcel);
    }

    public Word[] newArray()
    {
      return null;
    }
  };
  private String audioUrl;
  private String def;
  private String key;
  private String lang;
  private Date mCreateDate;
  private boolean mIsMyWord;
  private String mMemo;
  private String pron;
  private List<SentInfo> sentList;
  private List<String> suggList;
  private String userId = null;

  public Word()
  {
    this.key = null;
    this.lang = null;
    this.audioUrl = null;
    this.pron = null;
    this.def = null;
    this.suggList = new ArrayList();
    this.mMemo = null;
    this.sentList = new ArrayList();
  }

  public Word(Parcel paramParcel)
  {
    this.key = null;
    this.lang = null;
    this.audioUrl = null;
    this.pron = null;
    this.def = null;
    this.suggList = new ArrayList();
    this.mMemo = null;
    this.sentList = new ArrayList();
    this.audioUrl = paramParcel.readString();
    this.mCreateDate = StringUtil.StrToDate(paramParcel.readString());
    this.def = paramParcel.readString();
    this.key = paramParcel.readString();
    this.lang = paramParcel.readString();
    this.mMemo = paramParcel.readString();
    this.pron = paramParcel.readString();
    this.userId = paramParcel.readString();
  }

  public int describeContents()
  {
    return 0;
  }

  public String getAudioUrl()
  {
    return this.audioUrl;
  }

  public Date getCreateDate()
  {
    return this.mCreateDate;
  }

  public String getDef()
  {
    return this.def;
  }

  public String getKey()
  {
    return this.key;
  }

  public String getLang()
  {
    return this.lang;
  }

  public String getMemo()
  {
    return this.mMemo;
  }

  public String getPron()
  {
    return this.pron;
  }

  public List<SentInfo> getSentList()
  {
    return this.sentList;
  }

  public List<String> getSuggList()
  {
    return this.suggList;
  }

  public String getUserId()
  {
    return this.userId;
  }

  public List<Word> getWords(JSONArray paramJSONArray)
  {
    JSONObject localJSONObject;
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    if (i >= paramJSONArray.length())
      return localArrayList;
    Word localWord = new Word();
    try
    {
      while (true)
      {
        localJSONObject = paramJSONArray.getJSONObject(i);
        String str = localJSONObject.getString("word");
        localWord.setKey(str);
        localWord.setUserId(localJSONObject.getString("id"));
        localWord.setDef(localJSONObject.getString("def"));
        localWord.setWordMemo(localJSONObject.getString("description"));
        if (!(StringUtil.isEmpty(localJSONObject.getString("record_time"))))
          break label190;
        Date localDate = IKnow.mIKnowDataBase.getWordInfo(str).getCreateDate();
        if (localDate == null)
          break;
        localWord.setCreateDate(localDate);
        localWord.setAudioUrl(localJSONObject.getString("audio_url"));
        localWord.setLang(localJSONObject.getString("lang"));
        localArrayList.add(localWord);
        ++i;
      }
      label190: localWord.setCreateDate(new Date());
    }
    catch (JSONException localJSONException)
    {
      while (true)
        localJSONException.printStackTrace();
      localWord.setCreateDate(StringUtil.StrToDate(localJSONObject.getString("record_time")));
    }
  }

  public boolean isMyWord()
  {
    return this.mIsMyWord;
  }

  public void setAudioUrl(String paramString)
  {
    this.audioUrl = paramString;
  }

  public void setCreateDate(Date paramDate)
  {
    this.mCreateDate = paramDate;
  }

  public void setDef(String paramString)
  {
    this.def = paramString;
  }

  public void setIsMyWord(boolean paramBoolean)
  {
    this.mIsMyWord = paramBoolean;
  }

  public void setKey(String paramString)
  {
    this.key = paramString;
  }

  public void setLang(String paramString)
  {
    this.lang = paramString;
  }

  public void setPron(String paramString)
  {
    this.pron = paramString;
  }

  public void setSentList(List<SentInfo> paramList)
  {
    this.sentList = paramList;
  }

  public void setSuggList(List<String> paramList)
  {
    this.suggList = paramList;
  }

  public void setUserId(String paramString)
  {
    this.userId = paramString;
  }

  public void setWordMemo(String paramString)
  {
    this.mMemo = paramString;
  }

  public void writeToParcel(Parcel paramParcel, int paramInt)
  {
    paramParcel.writeString(getUserId());
    paramParcel.writeString(getKey());
    paramParcel.writeString(getAudioUrl());
    paramParcel.writeString(getDef());
    paramParcel.writeString(getMemo());
    paramParcel.writeString(getPron());
    paramParcel.writeString(getLang());
    paramParcel.writeString(StringUtil.DateToStr(getCreateDate()));
  }

  public static class SentInfo
  {
    private String audioUrl;
    private String orig = null;
    private String trans = null;

    public SentInfo()
    {
      this.audioUrl = null;
    }

    public String getAudioUrl()
    {
      return this.audioUrl;
    }

    public String getOrig()
    {
      return this.orig;
    }

    public String getTrans()
    {
      return this.trans;
    }

    public void setAudioUrl(String paramString)
    {
      this.audioUrl = paramString;
    }

    public void setOrig(String paramString)
    {
      this.orig = paramString;
    }

    public void setTrans(String paramString)
    {
      this.trans = paramString;
    }
  }
}